package com.example.demo.springboot.mqclient.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * OneConsumer:直推队内
 * 由于一对一的模式,建议@RabbitListener直接写在类上,但是如果一对一的很多,写在方法也未必不可
 * queuesToDeclare:沒有队列就自动生成的意识
 *
 * @author zhangxiaoxiang
 * @date 2020/11/16
 */
@Component
@Slf4j
public class OneConsumer {


    @RabbitListener(queuesToDeclare = @Queue("outbound.calllog.one.queue"))
    public void crmListener(Channel channel, Message message, String msg) {
        log.info("crm系统收到外呼话单回调[执行业务逻辑]:{},通道:{},消息:{}", msg, channel, message);
    }

    // 多个这种可以做成轮训的效果,因为只能被消费一次
    // @RabbitListener(queuesToDeclare = @Queue("outbound.calllog.one.queue"))
    // public void zhiYuListener(Channel channel, Message message, String msg) {
    //     log.info("zhiYu系统收到外呼话单回调[执行业务逻辑]:{},通道:{},消息:{}", msg, channel, message);
    // }
}
